import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
//routes数组中的元素，都在App.vue中的router-view里切换
const routes = [
  {
    //如果直接访问根目录
    path: '/',
    //重定向到登录页
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/IndexView.vue'),
    //如果该页面中有router-view，定义children数组，将子页面保存在此处
    children:[
      {
        path: '/warehouse',
        name: 'warehouse',
        component: () => import('../views/WarehouseView.vue')
      },
      {
        path: '/warehouseArea',
        name: 'warehouseArea',
        component: () => import('../views/WarehouseAreaView.vue')
      },
      {
        path: '/mapDemo',
        name: 'mapDemo',
        component: () => import('../views/MapDemoView.vue')
      },
      {
        path: '/bar',
        name: 'bar',
        component: () => import('../views/BarView.vue')
      },
      {
        path: '/pie',
        name: 'pie',
        component: () => import('../views/PieView.vue')
      },
      {
        path: '/sysUser',
        name: 'sysUser',
        component: () => import( '../views/SysUserView.vue')
      },
      {
        path: '/material',
        name: 'material',
        component: () => import( '../views/MaterialView.vue')
      }
    ]
  },
  
]

const router = new VueRouter({
  routes
})

export default router
